package com.woody.aggregate.shop.enums.es;

import com.woody.aggregate.shop.enums.ShopShowTypeEnum;
import com.woody.aggregate.shop.enums.ParentShopShowTypeEnum;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * &copy; All rights Reserved
 * 门店在列表中的显示方式
 * @author wénkǎi.zhāng 2025-04-07
 */
@Getter
@RequiredArgsConstructor
public enum EsShopListDisplayType {
    /**
     * 不显示
     */
    HIDDEN(0),

    /**
     * 列表中显示
     */
    LIST(1),

    /**
     * 商圈中显示
     */
    BD(2),

    /**
     * 默认在商圈内展示
     */
    DEFAULT(EsShopListDisplayType.BD.getType());

    /**
     * 显示方式
     */
    private final Integer type;

    /**
     * 根据商圈配置的主门店展示方式，转换为ES枚举
     *
     * @param parentShopShowTypeEnum
     * @return
     */
    public static EsShopListDisplayType fromParentShopShowType(ParentShopShowTypeEnum parentShopShowTypeEnum) {
        if (ParentShopShowTypeEnum.LIST.equals(parentShopShowTypeEnum)) {
            return EsShopListDisplayType.LIST;
        }

        if (ParentShopShowTypeEnum.BD.equals(parentShopShowTypeEnum)) {
            return EsShopListDisplayType.BD;
        }

        throw new IllegalArgumentException("未知主门店展示方式:" + (parentShopShowTypeEnum == null ? "null" : parentShopShowTypeEnum.toString()));
    }


    /**
     * 根据商圈配置的门店展示方式，转换为ES枚举
     *
     * @param shopShowTypeEnum
     * @return
     */
    public static EsShopListDisplayType fromShopShowType(ShopShowTypeEnum shopShowTypeEnum) {
        if (ShopShowTypeEnum.LIST.equals(shopShowTypeEnum)) {
            return EsShopListDisplayType.LIST;
        }

        if (ShopShowTypeEnum.BD.equals(shopShowTypeEnum)) {
            return EsShopListDisplayType.BD;
        }

        throw new IllegalArgumentException("未知门店展示方式:" + (shopShowTypeEnum == null ? "null" : shopShowTypeEnum.toString()));
    }
}
